import apiMixin from '@/mixin/apiMixin';
import taskMixin from '@/mixin/taskMixin';

import uilts from '@/utils/index';
export default {
    mixins: [apiMixin,taskMixin],
    data() {
        return {
            loading: false,
            tableData:[],
            taskNumsTotal: 0,
            searchTypeList: [
                { value: "task_title", name: "任务标题" },
                { value: "user_name", name: "用户昵称" },
                { value: "user_id", name: "用户ID" },
                { value: "user_tel", name: "手机号码" },
                { value: "task_id", name: "任务ID" }
            ],
            searchType: 'task_title',
            searchText: '',
            curPage: 1,
            status: [
                {
                    text: '待发布',
                    value: '1'
                },
                {
                    text: '进行中',
                    value: '2'
                },
                {
                    text: '已完成',
                    value: '3'
                },
                {
                    text: '已关闭',
                    value: '4'
                },
                {
                    text: '清退中',
                    value: '5'
                },
                {
                    text: '已暂停',
                    value: '6'
                },
            ]
        }
    },
    mounted() {
        if (this.filterStatus == 0 || this.filterStatu) {
            this.$refs.filterTable.columns[6].filteredValue = this.filterStatus.split(',');
        }
        this.init();
    },
    methods: {
        init() {
            this.getTaskLsitApi(this.curPage)
        },
        getTaskLsitApi(page) {
            let _self = this;
            let resPar = {
                page: page,
                load: true,
                status: this.filterStatus
            };
            if(this.searchText) {
                resPar.type = this.searchType;
                resPar.keyword = this.searchText;
            }
            this.comResquest(this.request.getTaskList,(res)=>{
                _self.curPage = Number(page) || 1;
                _self.tableData = res.result;
                _self.taskNumsTotal = res.count;
                _self.updateRoutePar(page);
            },resPar)
        },
        changePage(page){
            page = page || 1;
            this.getTaskLsitApi(page);
        },
        /*changeTaskSpecStatus(type,listIndex) {
            let _self = this;
            let resPar = {
                load: true,
                id: this.tableData[listIndex].id
            };
            resPar.is_recommand = this.tableData[listIndex].is_recommand;
            resPar.is_top = this.tableData[listIndex].is_top;
            console.log(resPar);
            this.comResquest(this.request.postTaskList,(res)=>{
                _self.$message({
                    message: '修改成功',
                    type: 'success'
                });
            },resPar)
        },*/
        searchWill() {
            this.curPage = 1;
            this.getTaskLsitApi(1);
        },
        handleFilter(e) {
            console.log( e.status);
            this.filterStatus = e.status.join(',');
            this.getTaskLsitApi(1);
        }
    },
}